// me.js
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        address: '',
        controls: false,
        // danmuBtn:false,
        // danmuList:[],
        enableDanmu: false,
        autoPlay: true,
        // poster: "pages/img/faxian.png"
        // userInfo: {}

        items: [{
            mode: "scaleToFill",
            src: "../img/me01.png",
        }, {
            mode: "scaleToFill",
            src: "../img/me02.png",
        }, {
            mode: "scaleToFill",
            src: "../img/me01.png",
        }, {
            mode: "scaleToFill",
            src: "../img/me02.png",
        }, {
            mode: "scaleToFill",
            src: "../img/me01.png",
        }, {
            mode: "scaleToFill",
            src: "../img/me02.png",
        }]



    },
    // loadimage: function() {
    //     var that = this;
    //     that.setData({
    //         hiddenImage: !that.data.hiddenImage
    //     })
    //     var url = app.urls.CloudData.getList
    // },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        var that = this
        that.getuserInfo();
        that.dingwei();
        //调用应用实例的方法获取全局数据
        app.getUserInfo(function(userInfo) {
            //更新数据
            that.setData({
                userInfo: userInfo,

            })
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    getuserInfo: function() {
        var that = this;
        var session_key = wx.getStorageSync('session_key');
        console.log(session_key)
        wx.request({
            url: 'http://sheying.j8j0.com/api/user/user_info',
            method: 'POST',
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            data: {

                session_key: session_key
            },
            success: function(res) {
              console.log('res',res);

                that.setData({
                    interact: res.data.data.interact,
                    video: res.data.data.video,
                    user_info: res.data.data.user_info
                })
            },
            fail: function(res) {
                console.log(res)
            }
        })
    },
    bindReset: function() {
        wx.navigateTo({
            url: '../index/reset/reset'
        })
    },
    dingwei: function() {
        var that = this

        wx.getLocation({
            type: 'wgs84',
            success: function(res) {
                console.log(res)
                var latitude = res.latitude;
                var longitude = res.longitude;
                var speed = res.speed;
                var accuracy = res.accuracy;　
                // wx.request({　
                //     url: 'http://api.map.baidu.com/geocoder/v2/?ak=btsVVWf0TM1zUBEbzFz6QqWF&callback=renderReverse&location=' + res.latitude + ',' + res.longitude + '&output=json&pois=1',
                //     data: {},
                //     header: { 'Content-Type': 'application/json' },
                //     success: function(ops) {
                //         console.log('地址', ops.data)　
                //     }　　　　
                // })
                wx.request({
                    url: 'http://apis.map.qq.com/ws/geocoder/v1/?location=' + latitude + ',' + longitude + '&key=HLEBZ-6KYC4-KREUS-XHUJE-V5ZH5-3HBJ4',
                    data: {},
                    header: { 'Content-Type': 'application/json' },
                    success: function(ops) {
                        console.log('dizhi2', ops.data)　
                        that.setData({
                            // address: ops.data.result.address,
                            address: ops.data.result.address_component.city + '·' + ops.data.result.address_component.district
                        })
                    }　　　　
                })
            }
        })

    },
    videoPlay: function(e) {
        e.currentTarget.id
    },
    bindRevise: function() {
        wx.navigateTo({
            url: '../index/reset/revise/revise'
        })
    },
    bindguanzhu: function() {
        wx.navigateTo({
            url: 'pengyou/pengyou?url=' + '/api/Discover/concern_info'
        })
    },
    binddianzan: function() {
        wx.navigateTo({
            url: 'pengyou/pengyou?url=' + '/api/Discover/mind_info'
        })
    },
    bindshoucang: function() {
        wx.navigateTo({
            url: 'pengyou/pengyou?url=' + '/api/Discover/favorites_info'
        })
    }
})